package com.bluezone.dec.utils;

import lombok.extern.slf4j.Slf4j;
import org.springframework.util.StreamUtils;

import java.io.*;
import java.nio.charset.StandardCharsets;

@Slf4j
public class JSONUtils {

    private JSONUtils() {
    }

    /* 根据文件名读取 .json文件 */
    public static String getJsonFile(String filename) {
        String json = null;
        InputStream inputStream = JSONUtils.class.getClassLoader().getResourceAsStream("json/" + filename);
        try {
            json = StreamUtils.copyToString(inputStream, StandardCharsets.UTF_8);
        } catch (IOException e) {
            log.error("文件读取异常");
        }
        return json;
    }

}
